﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QuanLy_NhaSach
{
    public partial class Tracuusach : Form
    {
        public Tracuusach()
        {
            InitializeComponent();
        }

        private void Tracuusach_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'nhaSachDataSet.LoaiSach' table. You can move, or remove it, as needed.
            //this.loaiSachTableAdapter.Fill(this.nhaSachDataSet.LoaiSach);
            sachBindingSource.DataSource = NhaSachBUS.SachBUS.LoadSach();
            //loaiSachBindingSource.DataSource = NhaSachBUS.LoaiSachBUS.LoadLoaiSach();
            loaiSachBindingSource1.DataSource = NhaSachBUS.LoaiSachBUS.LoadLoaiSach();
        }

        private void thoat_Click(object sender, EventArgs e)
        {
            
           closeForm();
            
        }

        public void closeForm()
        {
            this.Dispose();
        }

        private void tracuu_Click(object sender, EventArgs e)
        {
            if (txttracuu.Text != "")
                sachBindingSource.DataSource=  NhaSachBUS.SachBUS.TheoTen(txttracuu.Text);

            else if (txttacgia.Text != "")
                sachBindingSource.DataSource = NhaSachBUS.SachBUS.TheoTacGia(txttacgia.Text);
            else
                sachBindingSource.DataSource = NhaSachBUS.SachBUS.TheoTheLoai(maLoaiTextBox.Text);
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void tenLoaiLabel_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            sachBindingSource.DataSource = NhaSachBUS.SachBUS.LoadSach();
        }

        private void button2_Click(object sender, EventArgs e)
        {
        CloseForm();
        }

        private void CloseForm()
        {
            this.Dispose();
        }
    }
}
